package com.msda.config;

import com.msda.interceptor.LoginInterceptor;
import com.msda.mapper.TokenMapper;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Autowired
    private TokenMapper tokenMapper;

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        //登录拦截器
        registry.addInterceptor(new LoginInterceptor(tokenMapper))
                .excludePathPatterns(
                        "/user/add_user",
                        "/user/register_user",
                        "/user/login_user",
                        "/user/auto_login_user",
                        "/user/customer/inquire/**",
                        "/user/customer/quash_register/**",
                        "/doc.html/**",
                        "/webjars/**",
                        "/v3/api-docs/**",
                        "/swagger-ui.html",
                        "/user/customer/register"
                ).order(1);
    }

}
